﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:local="clr-namespace:Microsoft.Samples.Kinect.BasicInteractions" 
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="{x:Type local:HoverDwellButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:HoverDwellButton}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ContentPresenter />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Storyboard x:Key="ScaleUp">
        <DoubleAnimation Storyboard.TargetProperty="(local:HoverDwellButton.RenderTransform).(ScaleTransform.ScaleX)"
                         From="1" To="1.05" Duration="0:0:0.5" />
        <DoubleAnimation Storyboard.TargetProperty="(local:HoverDwellButton.RenderTransform).(ScaleTransform.ScaleY)"
                         From="1" To="1.05" Duration="0:0:0.5" />
    </Storyboard>
    <Storyboard x:Key="ScaleDown">
        <DoubleAnimation Storyboard.TargetProperty="(local:HoverDwellButton.RenderTransform).(ScaleTransform.ScaleX)"
                         From="1.05" To="1.0" Duration="0:0:0.5" />
        <DoubleAnimation Storyboard.TargetProperty="(local:HoverDwellButton.RenderTransform).(ScaleTransform.ScaleY)"
                         From="1.05" To="1.0" Duration="0:0:0.5" />
    </Storyboard>

    <Style x:Key="EnlargingHoverDwellButton" TargetType="{x:Type local:HoverDwellButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:HoverDwellButton}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ContentPresenter />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
        <Style.Triggers>
            <Trigger Property="IsHoveredOver" Value="true">
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource ScaleUp}" />
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource ScaleDown}" />
                </Trigger.ExitActions>
            </Trigger>
        </Style.Triggers>

    </Style>

    <Style x:Key="VerticalScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid x:Name="Grid" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="72" />
                            <ColumnDefinition Width="2" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                                CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"
                                                ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0"
                                                Margin="{TemplateBinding Padding}" Grid.Row="0" />

                        <ScrollBar x:Name="PART_VerticalScrollBar"
                                               AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1"
                                               Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Grid.RowSpan="2"
                                               Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                               Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                               ViewportSize="{TemplateBinding ViewportHeight}" Margin="0,10,10,0" Style="{DynamicResource ScrollBarStyle}">
                        </ScrollBar>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid x:Name="Grid" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="72" />
                            <RowDefinition Height="2" />
                        </Grid.RowDefinitions>
                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                                CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False"
                                                ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0"
                                                Margin="{TemplateBinding Padding}" Grid.Row="0" />

                        <ScrollBar x:Name="PART_HorizontalScrollBar"
                                               AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Grid.ColumnSpan="2"
                                               Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1"
                                               Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                               Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                                               ViewportSize="{TemplateBinding ViewportWidth}" Margin="0,0,0,10" Style="{DynamicResource ScrollBarStyle}">
                        </ScrollBar>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
    <SolidColorBrush x:Key="NormalBrush" Color="#888" />
    <SolidColorBrush x:Key="NormalBorderBrush" Color="#888" />
    <SolidColorBrush x:Key="HorizontalNormalBrush" Color="#888" />
    <SolidColorBrush x:Key="HorizontalNormalBorderBrush" Color="#888" />
    <SolidColorBrush x:Key="GlyphBrush" Color="#444" />
    <LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="#BBB" Offset="0.0" />
                <GradientStop Color="#EEE" Offset="0.1" />
                <GradientStop Color="#EEE" Offset="0.9" />
                <GradientStop Color="#FFF" Offset="1.0" />
            </GradientStopCollection>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <!--SrollViewer ScrollBar Repeat Buttons (at each end)-->
    <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border x:Name="Border" Margin="1" CornerRadius="2" Background="#FFD2D2D2"
                            BorderBrush="{StaticResource NormalBorderBrush}" BorderThickness="1">
                        <Path HorizontalAlignment="Center" VerticalAlignment="Center"
                              Fill="{StaticResource GlyphBrush}" Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--SrollViewer ScrollBar Repeat Buttons (The part in the middle, 
             not the thumb the long area between the buttons )-->
    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="{StaticResource DisabledColorBrush}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--ScrollViewer ScrollBar Thumb, that part that can be dragged
            up/down or left/right Buttons-->
    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Background" Value="#969696" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1">
                        <Grid>
                           
                        </Grid>
                    </Border>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Background" Value="#969696" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1">
                        <Grid>
                            
                        </Grid>
                    </Border>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="MiniVerticalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid Width="7">
            <Grid.RowDefinitions>
                <RowDefinition MaxHeight="2" />
                <RowDefinition Height="0.00001*" />
                <RowDefinition MaxHeight="2" />
            </Grid.RowDefinitions>
            <Border Grid.RowSpan="3" Background="Transparent" />
            <Track x:Name="PART_Track" Grid.Row="1" IsDirectionReversed="true">
                <Track.Resources>
                    <!-- Set the Thumb's minimum height to 150.
            The Thumb's minimum height is half the
            value of VerticalScrollBarButtonHeightKey. -->
                    <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">
                        300
                    </sys:Double>
                </Track.Resources>

                <Track.Thumb>
                    <Thumb x:Name="Part_Thumb" Margin="0,0,0,0" Background="{StaticResource ActiveScrollRegionBrush}"
                           BorderBrush="{StaticResource ActiveScrollRegionBrush}" />
                </Track.Thumb>
            </Track>
        </Grid>
    </ControlTemplate>
    
    <ControlTemplate x:Key="MiniHorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid Margin="0,0,0,0" Height="7">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="2" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition MaxWidth="2" />
            </Grid.ColumnDefinitions>
            <Border Grid.ColumnSpan="3" Background="Transparent" />

            <Track x:Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
                <Track.Resources>
                    <!-- Set the Thumb's minimum width to 150.
            The Thumb's minimum width is half the
            value of HorizontalScrollBarButtonWidthKey. -->
                    <sys:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}">
                        300
                    </sys:Double>
                </Track.Resources>

                <Track.Thumb>
                    <Thumb x:Name="Part_Thumb" Margin="0,0,0,0" Background="{StaticResource ActiveScrollRegionBrush}"
                           BorderBrush="{StaticResource ActiveScrollRegionBrush}">
                    </Thumb>
                </Track.Thumb>

            </Track>

        </Grid>

    </ControlTemplate>

    <Style x:Key="ScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto" />
                <Setter Property="Height" Value="7" />
                <Setter Property="Template" Value="{DynamicResource MiniHorizontalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Width" Value="7" />
                <Setter Property="Template" Value="{DynamicResource MiniVerticalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="AutoScrollCarouselItemsControl" TargetType="{x:Type ItemsControl}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <local:AutoScrollCarouselContainer>
                        <ContentPresenter
                            ContentTemplate="{Binding ItemTemplate, RelativeSource={RelativeSource AncestorType={x:Type local:AutoScrollCarousel}, Mode=FindAncestor}}" />
                    </local:AutoScrollCarouselContainer>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:AutoScrollCarouselContainer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:AutoScrollCarouselContainer}">
                    <Border x:Name="Border" BorderBrush="White" BorderThickness="0">
                        <ContentPresenter />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:AutoScrollCarousel}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:AutoScrollCarousel}">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" HorizontalAlignment="Left" VerticalAlignment="Top"
                            Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" x:Name="root" ClipToBounds="True">
                        <Border.Resources>
                            <local:VisibilityConverter x:Key="VisibilityConverter" />
                        </Border.Resources>
                        <StackPanel x:Name="PART_Scroller" Orientation="Horizontal" HorizontalAlignment="Left"
                                    VerticalAlignment="Center">
                            <ItemsControl x:Name="PART_Previous" Background="Transparent"
                                          Style="{StaticResource AutoScrollCarouselItemsControl}" ItemsSource="{TemplateBinding ItemsSource}"
                                          Visibility="{TemplateBinding IsLooping, Converter={StaticResource VisibilityConverter}}" />
                            <ItemsControl x:Name="PART_Current" Background="Transparent"
                                          Style="{StaticResource AutoScrollCarouselItemsControl}" ItemsSource="{TemplateBinding ItemsSource}" />
                            <ItemsControl x:Name="PART_Next" Background="Transparent"
                                          Style="{StaticResource AutoScrollCarouselItemsControl}" ItemsSource="{TemplateBinding ItemsSource}"
                                          Visibility="{TemplateBinding IsLooping, Converter={StaticResource VisibilityConverter}}" />
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:VideoPlayer}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:VideoPlayer}">
                    <local:HoverDwellButton Background="{TemplateBinding Background}"
                                        BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                                        x:Name="PART_PlayPauseButton">
                        <StackPanel Background="Black" IsHitTestVisible="False">
                            <MediaElement x:Name="PART_Media" LoadedBehavior="Manual"
                                          Source="{Binding Source, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:VideoPlayer}}}"
                                          ScrubbingEnabled="True" />
                            <Image x:Name="PART_PlayPause" Source="/Resources/Images/play.png" Width="70" Height="70"
                                   HorizontalAlignment="Center" />
                        </StackPanel>
                    </local:HoverDwellButton>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPlaying" Value="True">
                            <Setter TargetName="PART_PlayPause" Property="Source" Value="/Resources/Images/pause.png" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>